//
//  UIView+EJFrame.m
//  EJPhotoBrowser
//
//  Created by 刘爽 on 2020/5/30.
//  Copyright © 2020 LiuShuang. All rights reserved.
//

#import "UIView+EJFrame.h"

@implementation UIView (EJFrame)


- (CGFloat)ls_left {
    return self.frame.origin.x;
}

- (void)setLs_left:(CGFloat)ls_left {
    CGRect frame = self.frame;
    frame.origin.x = ls_left;
    self.frame = frame;
}

- (CGFloat)ls_top {
    return self.frame.origin.y;
}

- (void)setLs_top:(CGFloat)ls_top {
    CGRect frame = self.frame;
    frame.origin.y = ls_top;
    self.frame = frame;
}

- (CGFloat)ls_right {
    return self.frame.origin.x + self.frame.size.width;
}

- (void)setLs_right:(CGFloat)ls_right {
    CGRect frame = self.frame;
    frame.origin.x = ls_right - frame.size.width;
    self.frame = frame;
}

- (CGFloat)ls_bottom {
    return self.frame.origin.y + self.frame.size.height;
}

- (void)setLs_bottom:(CGFloat)ls_bottom {
    CGRect frame = self.frame;
    frame.origin.y = ls_bottom - frame.size.height;
    self.frame = frame;
}

- (CGFloat)ls_width {
    return self.frame.size.width;
}

- (void)setLs_width:(CGFloat)ls_width {
    CGRect frame = self.frame;
    frame.size.width = ls_width;
    self.frame = frame;
}

- (CGFloat)ls_height {
    return self.frame.size.height;
}

- (void)setLs_height:(CGFloat)ls_height {
    CGRect frame = self.frame;
    frame.size.height = ls_height;
    self.frame = frame;
}

- (CGFloat)ls_centerX {
    return self.center.x;
}

- (void)setLs_centerX:(CGFloat)ls_centerX {
    self.center = CGPointMake(ls_centerX, self.center.y);
}

- (CGFloat)ls_centerY {
    return self.center.y;
}

- (void)setLs_centerY:(CGFloat)ls_centerY {
    self.center = CGPointMake(self.center.x, ls_centerY);
}

- (CGPoint)ls_origin {
    return self.frame.origin;
}

- (void)setLs_origin:(CGPoint)ls_origin {
    CGRect frame = self.frame;
    frame.origin = ls_origin;
    self.frame = frame;
}

- (CGSize)ls_size {
    return self.frame.size;
}

- (void)setLs_size:(CGSize)ls_size {
    CGRect frame = self.frame;
    frame.size = ls_size;
    self.frame = frame;
}

+ (CGFloat)screenWidth {
    static dispatch_once_t onceToken;
    static CGFloat width = 0;
    dispatch_once(&onceToken, ^{
        CGSize size = [UIScreen mainScreen].bounds.size;
        width = MIN(size.width, size.height);
    });
    return width;
}

+ (CGFloat)screenHeight {
    static dispatch_once_t onceToken;
    static CGFloat height = 0;
    dispatch_once(&onceToken, ^{
        CGSize size = [UIScreen mainScreen].bounds.size;
        height = MAX(size.width, size.height);
    });
    return height;
}

@end
